<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="forumNavi.jsp"></jsp:include>
<c:if test="${empty topic}">
	<script type="text/javascript">
		$(function() {
			setTimeout(function() {
				window.location = 'index.do';
			}, 3000);
		});
	</script>
	<div class='autojump'>
		版块不存在或已删除<br /> <a href='index.do'>如果您的浏览器没有自动跳转，请点击此链接</a>
	</div>
</c:if>
<c:if test="${!empty topic}">
	<script>
		$(window).bind('resize', function()
		{
		    var width = $('.topic_panel').width();
		    $('.topic_td1').width(width - 265);
		});
		
		$(function(){
			function postnewfast_success(data) {
				if (data.state == 'success') {
					window.location = 'index.do?mod=post&id=' + data.newPostId;
				} else {
					alert('发表失败');
				}
			}
		
			$('#post_new_fast_form').ajaxForm({
				success : postnewfast_success
			});
			
			$('#topic_content tr').hover(function(){
				$(this).addClass('table_hover');
			},function(){
				$(this).removeClass('table_hover');
			});
		});
	</script>
	
	<jsp:include page="topicPage.jsp">
		<jsp:param value="Top" name="jumpPageInput"/>
	</jsp:include>
	
	<div class='gray_panel topic_panel'>
		<div class='gray_panel_header'>
			<table>
				<tr>
					<td class="topic_td1">
						筛选:
						<a href="javascript:;" class="showmenu">全部主题</a>
						<a href="javascript:;" class="showmenu">全部时间</a>
						排序:
						<a href="javascript:;" class="showmenu">最后发表</a>
						<span class="pipe">|</span>
						精华
						<span class="pipe">|</span>
						<a href="javascript:;" class="forum_refresh">&nbsp;</a>
					</td>
					<td class="topic_td2">作者</td>
					<td class="topic_td3">回复/查看</td>
					<td class="topic_td4">最后发表</td>
				</tr>
			</table>
		</div>
		<div id="topic_content" class='panel_content topic'>
			<table>
				<c:forEach var="post" items="${postList}">
					<tr>
						<td class="topic_td1"><img src="css/images/folder_new.gif"/><input type="checkbox"><a href="index.do?mod=post&id=${post.id}">${post.title}</a></td>
						<td class="topic_td2">${post.create_user_name}<br/>${post.create_time_readable}</td>
						<td class="topic_td3">${post.reply_num}/${post.view_num}</td>
						<td class="topic_td4">${post.last_update_user_name}<br/>${post.last_update_time_readable}</td>
					</tr>
				</c:forEach>
			</table>
		</div>
	</div>
	
	<jsp:include page="topicPage.jsp">
		<jsp:param value="Bottom" name="jumpPageInput"/>
	</jsp:include>
	
	<div class='gray_panel'>
		<div class='gray_panel_header'>快速发帖</div>
		<div class='panel_content'>
			<form id="post_new_fast_form" name="post_new_fast_form" action="forum/postNewFast.do" method="post">
				<div><input id="post_title" name="post_title"/></div>
				<div><input id="post_content" name="post_content"/></div>
				<div><button class='register_button' onclick="$('#post_new_fast_form').submit();return false;">发表帖子</button></div>
				<input id="topic_id" name="topic_id" type="hidden" value='${param.id}'/>
			</form>
		</div>
	</div>
</c:if>